﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HKEA.CMS.Core.IDAL.App;
using HKEA.CMS.Core.Models;
using HKEA.CMS.Core.DALFactory;
using HKEA.CMS.Core.Utility;
namespace HKEA.CMS.Core.BLL.App
{
    public class app_tblMediaRoom_RelatedBLL
    {
        private Iapp_tblMediaRoom_Related IDAL;

        public app_tblMediaRoom_RelatedBLL()
        {
            IDAL = DataAccess.CreateIapp_tblMediaRoom_Related();
        }

        public static app_tblMediaRoom_RelatedBLL GetInstance()
        {
            return new app_tblMediaRoom_RelatedBLL();
        }
        /// <summary>
        /// 插入一条记录，返回当前记录的UID ； 并非影响行数
        /// </summary>
        /// <param name="ent"></param>
        /// <returns></returns>
        public int InsertENT(app_tblMediaRoom_Related ent)
        {
            int ret=0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.InsertENT(ent); 
                }
                catch (Exception er)
                {
                    throw;
                }
            }
            return ret;
        }

        public List<app_tblMediaRoom_Related> GetMaxUIDRelatedENTByCustomerUID(app_tblMediaRoom_Related ent)
        {
            var ret = new List<app_tblMediaRoom_Related>();
            if (ent!=null)
            {
                try {
                    ret = IDAL.GetMaxAppRelatedENTByCUID(ent);
                }
                catch(Exception er)
                { throw; }
            }
            return ret;
        }

        public int SaveList(List<app_tblMediaRoom_Related> toadded,List<app_tblMediaRoom_Related> todeleted,List<app_tblMediaRoom_Related> toupdated)
        {
            try { return IDAL.SaveList(toadded, todeleted, toupdated); }
            catch (Exception er) { throw; }
            return 0;
        }

        public List<app_tblMediaRoom_Related> GetListByENT(app_tblMediaRoom_Related ent)
        {
            var ret = new List<app_tblMediaRoom_Related>();
            if (ent != null)
            {
                try
                {
                    ret = IDAL.GetListByENT(ent);
                }
                catch (Exception er)
                { throw; }
            }
            return ret;
        }
        public app_tblMediaRoom_Related GetEntity(app_tblMediaRoom_Related ent, bool isAddDeletedForSelect)
        {
            return IDAL.GetListByENT(ent, isAddDeletedForSelect).FirstOrDefault();
        }

        public List<app_tblMediaRoom_Related> GetListByENT(app_tblMediaRoom_Related ent, bool IsAddDeletedForSelect)
        {
            var ret = new List<app_tblMediaRoom_Related>();
            if (ent != null)
            {
                try
                {
                    ret = IDAL.GetListByENT(ent,IsAddDeletedForSelect);
                }
                catch (Exception er)
                { throw; }
            }
            return ret;
        }

        public List<M_MediaRoomRelatedDetail> GetList(app_tblMediaRoom_Related ent, bool IsAddDeletedForSelect)
        {
            List<M_MediaRoomRelatedDetail> list = new List<M_MediaRoomRelatedDetail>();
            if (ent != null)
            {
                try { list = IDAL.GetList(ent, IsAddDeletedForSelect); }
                catch (Exception er) { throw; }
            }
            return list;
        }

        public int UpdateENT(app_tblMediaRoom_Related ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.UpdateENT(ent);
                }
                catch (Exception er)
                { throw; }
            }
            return ret;
        }

        public int DeleteENT(app_tblMediaRoom_Related ent)
        {
            int ret = 0;
            if (ent != null)
            {
                try
                {
                    ret = IDAL.DeleteENT(ent);
                }
                catch (Exception er)
                { throw; }
            }
            return ret;
        }

        public List<Ext_MediaRoom> GetListWithMediaRoomByENT(Ext_MediaRoom ent)
        {
            List<Ext_MediaRoom> list = new List<Ext_MediaRoom>();
            if (ent != null)
            {
                try
                {
                    list = IDAL.GetListWithMediaRoomByENT(ent);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return list;
        }

        public List<Ext_MediaRoom> GetListWithMediaRoomByENT(Ext_MediaRoom ent, bool value)
        {

            List<Ext_MediaRoom> list = new List<Ext_MediaRoom>();
            if (value)
            {
                if (ent != null)
                {
                    try
                    {
                        list = IDAL.GetListWithMediaRoomByENT(ent,true);
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            return list;
        }
    }
}
